package com.ala4.oxcafe.repository;

import com.ala4.oxcafe.entity.MenuInfo;
import com.ala4.oxcafe.repository.mapper.MenuInfoMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 角色信息
 *
 * @author PING
 * @date 2025-03-25
 */
@Repository
public class MenuInfoRepository extends ServiceImpl<MenuInfoMapper, MenuInfo> implements IService<MenuInfo> {

    /**
     * 查询用户菜单
     *
     * @param userId
     * @return
     */
    public List<MenuInfo> userMenu(Long userId) {
        return this.baseMapper.selectUserMenu(userId);
    }

    /**
     * 删除子节点
     *
     * @param menuId 节点
     */
    public void deleteChildNode(Long menuId) {
        this.remove(Wrappers.<MenuInfo>lambdaQuery().likeRight(MenuInfo::getId, menuId));
    }

    public List<String> userMenuV2(Long userId) {
        return this.baseMapper.selectUserMenuV2(userId);
    }
}
